package com.example.provider.service.Impl;

import java.util.List;

import com.example.common.model.SquareArticle;
import com.example.common.model.condition.SquareArticleCondition;
import com.example.provider.mapper.SquareArticleMapper;
import com.example.provider.service.SquareArticleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

/**
 * 广场文章Service接口实现
 *
 * @author 510
 * @version 1.0.0 2021-04-23
 */
@Service
@Transactional(readOnly = true)
public class SquareArticleServiceImpl extends ServiceImpl<SquareArticleMapper, SquareArticle> implements SquareArticleService {
    private static final Logger logger = LoggerFactory.getLogger(SquareArticleService.class);

    @Override
    public IPage<SquareArticle> findSquareArticleByCondition(SquareArticleCondition condition) {
        IPage<SquareArticle> page = condition.buildPage();
        QueryWrapper<SquareArticle> queryWrapper = condition.buildQueryWrapper(SquareArticle.class);
        return this.page(page, queryWrapper);
    }

    @Override
    public SquareArticle getSquareArticleById(Integer sId) {
        return this.getById(sId);
    }

    @Transactional
    @Override
    public boolean addSquareArticle(SquareArticle squareArticle) {
        return this.save(squareArticle);
    }

    @Transactional
    @Override
    public boolean updateSquareArticle(SquareArticle squareArticle) {
        return this.updateById(squareArticle);
    }

    @Transactional
    @Override
    public boolean deleteSquareArticleById(Integer sId) {
        return this.removeById(sId);
    }

    @Transactional
    @Override
    public boolean deleteSquareArticleByIds(List<Integer> idList) {
        return this.removeByIds(idList);
    }
}